using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;

namespace DeathReportManagement.Controllers;

[Authorize]
public class HomeController : Controller
{
    public IActionResult Index()
    {
        // 根据用户角色重定向到相应页面
        if (User.IsInRole("Admin"))
        {
            return RedirectToAction("Index", "Admin");
        }
        else if (User.IsInRole("Doctor"))
        {
            return RedirectToAction("Index", "DeathReport");
        }
        
        // 默认重定向到登录页面
        return RedirectToAction("Login", "Account");
    }

    public IActionResult Error()
    {
        return View();
    }
}